//
//  DDUserAgreementVC.m
//  dingdang
//
//  Created by Jiangxp on 15/8/27.
//  Copyright (c) 2015年 阮 沧晖. All rights reserved.
//

#import "DDUserAgreementVC.h"

#define HexRGB(rgbValue)        [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

@interface DDUserAgreementVC ()

@end

@implementation DDUserAgreementVC

-(void)createUI
{
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationController.navigationBarHidden = YES;
    //自定义TAB BAR UI
    [self addNavigatorTitle:NSLocalizedString(@"用户协议", nil) parent:self.view];
    self.barViewControl.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"top_Background"]];
    
}

- (void)viewDidLoad {
    NSLog(@"进入到------>DDUserAgreementVC");
    [super viewDidLoad];
    [self createUI];
    [self AddLeftBtnAction:@"" normal:@"top_返回" selected:@"" action:^{
        [self.navigationController popViewControllerAnimated:YES];
    }];
    
    NSString *agreementStr = _textView.text;
    self.textView.attributedText = [self attributedString:agreementStr];
}


- (NSAttributedString *)attributedString:(NSString *)string {
    NSRange leftRange = [string rangeOfString:@"重要须知"];
    NSMutableAttributedString  *attriString = [[NSMutableAttributedString alloc] initWithString:string];
    
    NSDictionary *firstDic = [NSDictionary dictionaryWithObjectsAndKeys:HexRGB(0x000000),NSForegroundColorAttributeName,[UIFont boldSystemFontOfSize:24],NSFontAttributeName, nil];
    [attriString addAttributes:firstDic range:NSMakeRange(0, leftRange.location)];
    
    NSDictionary *secondDic = [NSDictionary dictionaryWithObjectsAndKeys:HexRGB(0x292421),NSForegroundColorAttributeName,[UIFont systemFontOfSize:16], NSFontAttributeName, nil];
    [attriString addAttributes:secondDic range:NSMakeRange(leftRange.location, string.length - leftRange.location)];
    
    return attriString;
}

@end
